<?php


namespace app\common\model;


use think\Model;

class JlLog extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type = [
        'amount'     => 'float',
        'jl_bili'     => 'float',
        'money'      => 'float',
    ];
    public function getPkAttr($value,$data) {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function dengji(){
        return $this->hasOne(UserLevel::class, 'level_id','level');
    }
    public function getStatusTextAttr($value,$data) {
        $status = [-1=>'待发放',1=>'待领取',2=>'已领取'];
        return $status[$data['status']];
    }
    public function getEndTimeTextAttr($value,$data) {
        if ($data['end_time']){
            return date($this->dateFormat,$data['end_time']);
        }
        return '---';
    }
}
